package com.example.network_android;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener {

	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setButtonListner();
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    private void setButtonListner(){
    	Button host = (Button)findViewById(R.id.button_host);
    	host.setOnClickListener(this);
    	
    	Button join = (Button)findViewById(R.id.button_join);
    	join.setOnClickListener(this);
    	
    }

	public void onClick(View v) {
		if (v.equals((Button)findViewById(R.id.button_host))){
			Log.d("Network_android","HOST" );
			
			Intent i = new Intent(this,HostActivity.class);
			
			startActivity(i);
		}
		if (v.equals((Button)findViewById(R.id.button_join))){
			Log.d("Network_android","JOIN" );
			
			EditText e = (EditText)findViewById(R.id.ip);
			
			Intent i = new Intent(this,ClientActivity.class);
			
			Bundle b = new Bundle();
			b.putString("ip", e.getText().toString()); //Your id
			i.putExtras(b); //Put your id to your next Intent
			
			startActivity(i);
		}
		
	}
}
